/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.icode.utils;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Hot_Girls
 */
public class RMIRequest<T> {
    public T gate;
    
    public RMIRequest(String interName){
        this.gate = this.getInterface(interName);
    }
    
    public T getInterface(String interName){
        try {
            return (T) Naming.lookup("rmi://localhost:2012/" + interName);
        } catch (NotBoundException ex) {
            Logger.getLogger(RMIRequest.class.getName()).log(Level.SEVERE, null, ex);
        } catch (MalformedURLException ex) {
            Logger.getLogger(RMIRequest.class.getName()).log(Level.SEVERE, null, ex);
        } catch (RemoteException ex) {
            Logger.getLogger(RMIRequest.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }
}
